home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freaks Macintosh Archive
/
Freaks Macintosh Archive.bin
/
Freaks Macintosh Archives
/
Hacking & Misc
/
UNIX Cracking
/
MacCracSource.sit
/
MacCrac.source
/
Source
/
crack-supp.c
< prev
next >
Wrap
Text File
|
1995-02-07
|
6KB
|
261 lines
/*
* This program is copyright Alec Muffett 1991 except for some portions of
* code in "crack-fcrypt.c" which are copyright Robert Baldwin, Icarus Sparry
* and Alec Muffett. The author(s) disclaims all responsibility or liability
* with respect to it's usage or its effect upon hardware or computer
* systems, and maintain copyright as set out in the "LICENCE" document which
* accompanies distributions of Crack v4.0 and upwards.
*/
#include "crack.h"
#include <time.h>
#include <stdio.h>
#define THEALERT 130
#define NIL 0L
int
gethostname (name, namelen)
char *name;
int namelen;
{
strcpy(name, "Macintosh");
namelen = 9;
}
/* special note at bottom of screen */
void
SysLog (fmt, a, b, c, d, e, f, g, h, i, j)
char *fmt;
long int a, b, c, d, e, f, g, h, i, j;
{
Point penplace, originalpen;
GrafPtr thePort;
Rect tempRect;
char buffer[STRINGSIZE], buffer2[STRINGSIZE];
time_t t;
time(&t);
sprintf (buffer,"MacCrac - %-15.15s ", ctime (&t) + 4);
sprintf (buffer2,fmt, a, b, c, d, e, f, g, h, i, j);
GetPort(&thePort);
GetPen(&originalpen);
MoveTo(0, (thePort->portRect.bottom) - 10);
ForeColor(whiteColor);
BackColor(magentaColor);
DrawText (buffer, 0, strlen(buffer) );
DrawText (buffer2, 0, strlen(buffer2));
/* draw box to end of window */
BackColor(magentaColor);
ForeColor(magentaColor);
GetPen(&penplace);
tempRect.top = (penplace.v) - 10;
tempRect.left = (penplace.h);
tempRect.bottom = (penplace.v) + 2;
tempRect.right = (thePort->portRect.right);
PaintRect(&tempRect);
ForeColor(blackColor);
BackColor(whiteColor);
MoveTo(originalpen.h, originalpen.v);
}
/* log anything to datafile. */
void
Log (fmt, a, b, c, d, e, f, g, h, i, j)
char *fmt;
long int a, b, c, d, e, f, g, h, i, j;
{
time_t t;
FILE *fp;
Str255 badlog = "Error opening Logfile.";
char buffer[STRINGSIZE], buffer2[STRINGSIZE];
GrafPtr thePort;
Point penplace;
TEHandle docTE;
Rect tempRect;
time (&t);
/* ALWAYS WRITE TO A LOG */
if ((fp = fopen (opfile, "a")) == NULL)
{
ParamText(badlog, NIL, NIL, NIL);
Alert (THEALERT, NIL);
exit(1);
}
fprintf (fp,"pwc: %-15.15s ", ctime (&t) + 4);
fprintf (fp,fmt, a, b, c, d, e, f, g, h, i, j);
fclose (fp);
/* sometimes write to the screen */
if (foreground_bool)
{
sprintf (buffer,"pwc: %-15.15s ", ctime (&t) + 4);
sprintf (buffer2,fmt, a, b, c, d, e, f, g, h, i, j);
GetPort(&thePort);
GetPen(&penplace);
Move(-(penplace.h),13);
if (penplace.v >= (thePort->portRect.bottom - 35))
{
MoveTo(0,10);
/* ScrollRect(&thePort->portRect, 0, -20, thePort->visRgn);*/
}
DrawText (buffer, 0, strlen(buffer) );
DrawText (buffer2, 0, (strlen(buffer2) -1 ));
/* draw box to end of window */
ForeColor(whiteColor);
GetPen(&penplace);
tempRect.top = (penplace.v) - 13;
tempRect.left = (penplace.h);
tempRect.bottom = (penplace.v);
tempRect.right = (thePort->portRect.right);
PaintRect(&tempRect);
ForeColor(blackColor);
}
}
/* print a guess, giving a single place to mod where necessary */
void
PrintGuess (eptr, guess)
register struct USER *eptr;
char *guess;
{
eptr -> done = 1;
eptr -> passwd_txt = Clone (guess); /* ESSENTIAL to FeedBack() */
if (!eptr -> passwd_txt)
{
eptr -> passwd_txt = "<Ran out of memory logging this password>";
}
ForeColor(redColor);
Log ("Guessed %s%s (%s in %s) [%s] %s\n",
(eptr -> passwd.pw_uid ? "" : "ROOT PASSWORD "),
eptr -> passwd.pw_name,
eptr -> passwd.pw_shell,
eptr -> filename,
guess,
eptr -> passwd.pw_passwd);
if (foreground_bool)
SysLog("PASSWORD(S) FOUND THIS SESSION! Check the log.");
}
/* write a pointfile out */
int
SetPoint (dict, rule, usernum, username)
char *dict;
char *rule;
int usernum;
char *username;
{
FILE *fp;
time_t t;
Str255 badpoint = " Error opening Point File for writing.";
if (!(fp = fopen (pointfile, "w")))
{
ParamText(badpoint, NIL, NIL, NIL);
Alert (THEALERT, NIL);
return (-1);
}
time (&t);
fprintf (fp, "host=%s pid=%d pointtime=%s", this_hostname, pid, ctime (&t));
fprintf (fp, "%s\n", this_hostname);
fprintf (fp, "%s\n", dict);
fprintf (fp, "%s\n", rule);
fprintf (fp, "%d\n", usernum);
fprintf (fp, "%s\n", username);
fclose (fp);
return (0);
}
/* read a pointfile in... */
int
GetPoint (pf)
char *pf;
{
FILE *fp;
char buffer[STRINGSIZE];
if (!(fp = fopen (pf, "r")))
{
SysLog("Error: Can't open Point File for reading.");
Log ("Error: Can't open Point File for reading.");
return (-1);
}
/* junk */
if (!fgets (buffer, STRINGSIZE, fp))
{
return (-2);
}
/* hostname */
if (!fgets (old_hostname, STRINGSIZE, fp))
{
return (-3);
}
/* dictname */
if (!fgets (old_dictname, STRINGSIZE, fp))
{
return (-4);
}
/* rule */
if (!fgets (old_rule, STRINGSIZE, fp))
{
return (-5);
}
/* usernum */
if (!fgets (buffer, STRINGSIZE, fp))
{
return (-6);
}
/* username */
if (!fgets (old_username, STRINGSIZE, fp))
{
return (-7);
}
Trim (old_hostname);
if (strcmp (old_hostname, this_hostname))
{
return (-8);
}
Trim (old_dictname);
Trim (old_rule);
old_usernum = atoi (buffer);
Trim (old_username);
fclose (fp);
return (0);
}